<div class="bjui-pageHeader">
    <form id="pagerForm" data-toggle="ajaxsearch" action="{{url('admin/user')}}" method="get">
        <input type="hidden" name="_token" value="{{ csrf_token() }}">
        <input type="hidden" name="page" value="{{$users->currentPage()}}">
        <input type="hidden" name="orderField" value="{{$request->input('orderField', 'id')}}">
        <input type="hidden" name="orderDirection" value="{{$request->input('orderDirection', 'asc')}}">

        <div class="bjui-searchBar">
            <label>角色：</label>
            <select name="role_id" data-toggle="selectpicker">
                <option value="">全部</option>
                @foreach($roles as $role)
                    <option value="{{$role->id}}" <?=$request->input('role_id') == $role->id ? 'selected' : ''?>>{{$role->name}}</option>
                @endforeach
            </select>&nbsp;
            <label>姓名：</label><input name="name" size="10" value="{{$request->input('name')}}">
            <button type="submit" class="btn-default" data-icon="search">查询</button>
            &nbsp;
            <a class="btn btn-orange" href="javascript:;" onclick="$(this).navtab('reloadForm', true);"
               data-icon="undo">清空查询</a>

            <div class="pull-right">
                <a class="btn btn-default" data-icon="plus" href="{{url('admin/user/add')}}" data-toggle="dialog"
                   data-id="user_add"
                   data-title="添加用户" data-width="900" data-height="600" data-mask="true">增加</a>
            </div>
        </div>
    </form>
</div>
<div class="bjui-pageContent">
    <table data-toggle="tablefixed" data-width="100%" data-nowrap="true">
        <thead>
        <tr>
            <th width="40">id</th>
            <th>姓名</th>
            <th>性别</th>
            <th>邮箱地址</th>
            <th>手机号码</th>
            <th>地址</th>
            <th>注册时间</th>
            <th>角色</th>
            <th width="100">操作</th>
        </tr>
        </thead>
        <tbody>
        @foreach($users as $user)
            <tr data-id="{{$user->id}}">
                <td>{{$user->id}}</td>
                <td>{{$user->name}}</td>
                <td>{{$genders[$user->gender]}}</td>
                <td>{{$user->email}}</td>
                <td>{{$user->phone}}</td>
                <td>{{$user->address}}</td>
                <td>{{$user->created_at}}</td>
                <td>{{$user->role->name}}</td>
                <td>
                    <a href="{{url('/admin/user/edit/' . $user->id)}}" class="btn btn-green" data-toggle="dialog"
                       data-id="user_edit"
                       data-title="编辑-{{$user->name}}" data-width="900" data-height="600" data-mask="true">编辑</a>
                    @if($user->id != Auth::user()->id)
                        <a href="{{url('/admin/user/delete/' . $user->id)}}" class="btn btn-red" data-toggle="doajax"
                           data-type="get"
                           data-confirm-msg="确定要删除该行信息吗？">删除</a>
                    @endif
                </td>
            </tr>
        @endforeach
        </tbody>
    </table>
</div>
<div class="bjui-pageFooter">
    <div class="pages">
        <span>每页{{config('view')['numPerPage']}}条，共 {{$users->total()}} 条</span>
    </div>
    <div class="pagination-box" data-toggle="pagination" data-total="{{$users->total()}}"
         data-page-size="{{config('view')['numPerPage']}}"
         data-page-current="{{$users->currentPage()}}"></div>
</div>